package com.fz.us.admin.base.bean.search.result;

import com.fz.us.admin.base.bean.search.Search;
import org.springframework.util.Assert;

import java.util.List;

/**
 * 查询 - 结果 - SearchResultList
 * ============================================================================
 * 版权所有 2016 。
 *
 * @author fallenpanda
 * @version 1.0 2016-07-13 。
 * ============================================================================
 */
public class SearchResultList extends SearchResult {

    protected final List list;

    public List getList() {
        return list;
    }

    protected SearchResultList(Search search, List list) {
        super(search);
        this.list = list;
    }

    public static SearchResultList list(Search search, List list) {
        return newBuilder().setSearch(search).setList(list).build();
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public static class Builder extends SearchResult.Builder<SearchResult, Builder> {

        protected List list;

        @Override
        protected Builder getThis() {
            return this;
        }

        public Builder setList(List list) {
            this.list = list;
            return this;
        }

        @Override
        public SearchResultList build() {
            Assert.notNull(search, "search 不能为空");
            Assert.notNull(list, "list 不能为空");
            return new SearchResultList(search, list);
        }

    }


}
